# encoding: utf-8

from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext import db

class User(db.Model):
    Name = db.StringProperty()
    Passwd = db.StringProperty()
    AddDate = db.DateTimeProperty()

class MainPage(webapp.RequestHandler):
    def get(self):
        count = self.request.get("count")
        if count:
            count = int(count)
        else:
            count = 1000
        users = User.gql('ORDER BY AddDate LIMIT %s' % count); 
        db.delete(users.fetch(count))
        self.response.headers['Content-Type'] = 'text/plain'
        self.response.out.write('Succ!')
        
application = webapp.WSGIApplication([('/.*', MainPage)], debug=True)

def main():
    run_wsgi_app(application)

if __name__ == "__main__":
    main()
